home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / May 96 / Re Forcing a draw.5 < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  5.2 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Forcing a draw
  2. Sent:        5/18/96 7:31 AM
  3. Received:    5/22/96 8:31 AM
  4. From:        Arni McKinley, motion@nbn.com
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >Bill Finzer
  9. >Key Curriculum Press
  10.  
  11. >In a DoMouseDown of a subView, the user is dragging a point in a graph, thus
  12. >changing the data in the model layer. The model has dependents, including
  13. >some views, which are notified of the change. The views need to redraw
  14. >themselves immediately; i.e., without waiting for an update, so that the user
  15. >gets feedback about the effects of the drag during the drag.
  16. >
  17. >I have been unable to discover any way to force an immediate redraw of an
  18. >individual view. Can anyone help me?
  19.  
  20.  
  21. Bill,
  22.  
  23. The solution to your particular problem has to do with the following insight:
  24. A given part content may appear in several frames. It should happen that
  25. when you change that content it should change everywhere. On the other
  26. hand, each frame is a unique presentation of the content; you should be
  27. able to change the drawing of that presentation of the content
  28. independently of what is being shown in other frames. One frame may show a
  29. larger scaled drawing of the content than another for example, or it may
  30. show the content scrolled, or may show a different presentation entirely
  31. (say a 3D presentation).
  32.  
  33. Finally any given frame may be showing its particular presentation through
  34. various facets and every facet whould be showing exactly the same drawing
  35. of that presentation as every other facet.
  36.  
  37. A simple example of multiple frames is this: Suppose your part is embedded
  38. in a container. It is being seen by the user through one frame; now the
  39. user opens the part and sees it through a window ("View In Window"). There
  40. are now two frames open showing the same content.
  41.  
  42. How to achieve this in ODF?
  43. (1) Make sure that the content is carried by your part code. DR1 now has a
  44. "FW_CContent" which takes care of carrying content. You can use that for
  45. the part; ODFDraw has several very good example of its use.
  46. (2) Make sure that all variables which describe the view of the content are
  47. carried by the frame and its subviews. The frame is now a FW_CSuperView. A
  48. scaling factor for example is a good variable to keep in the frame or its
  49. main subview.
  50. (3) Make sure that you use the Draw() method of the frame to draw larger
  51. frame related things, like outlines around the frame etc, and the subviews
  52. to draw their own things (the main view would draw the content). Just what
  53. draws what is somewhat arbitrary, but there are some considerations
  54. depending upon the content.
  55. (4) Generally all drawing is done automatically on the update. Generate
  56. updates by calling "view->Invalidate(ev)". Including a rectangle or ODShape
  57. will isolate the update region effectively; leaving them out invalidates
  58. the entire view shape. There is a third parameter in DR1 (I forget if it
  59. was in d11, but I don't think so) which allows you to specify whether to
  60. invalidate the same view in all frames. This is useful if you change the
  61. content of the part and want the frames to change their views accordingly.
  62. (5) Since frames all have a different FW_CPresentation, invalidations are
  63. actually shipped through the frame's presentation. You can do the same if
  64. you want to invalidate directly, though this isn't usually necessary.
  65. Invalidate does it better. For example:
  66. frame->GetPresentation()->Invalidate()
  67. (6) Suppose you have an object you want to redraw wihtin a single facet at
  68. an odd time, like a shape during a mouseDown. You can get hold of the facet
  69. within which a mouseDown has occurred by asking the mouseEvent:
  70.         ODFacet* theFacet = theMouseEvent.GetFacet(ev);
  71.         FW_CViewContext vc(ev, this, theFacet );
  72.         theShape->RenderShape(ev, theFacet, vc);
  73. (7) Suppose you want to set the time in a display area while a simulation
  74. is one frame is underway and you don't want to wait for the update. You
  75. might do this:
  76.  
  77. void ContrlrFrame::SetCurrentTime( Environment *ev, FW_Double time )
  78. {
  79.         fContrlrView->SetCurrentTime( ev, time );
  80.  
  81.         // Now draw thie current time to all of the frame's facets
  82.         //              Acquire it since we get rid of it locally
  83.         FW_CAcquiredODShape invalidShape = fContrlrView->GetPresTextShape(ev);
  84.         DrawAllFacets( ev, invalidShape );
  85. }
  86. void ContrlrFrame::DrawAllFacets( Environment *ev, ODShape *invalidShape )
  87. {
  88.         FW_CFrameFacetIterator facetIte(ev, this);
  89.         for (ODFacet* facet = facetIte.First(ev);
  90. facetIte.IsNotComplete(ev); facet = facetIte.Next(ev))
  91.         {
  92.                 Draw( ev, facet, invalidShape );
  93.  
  94.                 FW_CAcquiredODShape aqClipShape =
  95. facet->AcquireAggregateClipShape(ev, NULL);
  96.                 fContrlrView->Draw(ev, facet, aqClipShape );
  97.         }
  98. }
  99.  
  100. Notice that setting the time in this context is something that happens in a
  101. given frame. All of the other frames could be running their simulations
  102. simultaneously. The part content is the shapes; the content is being viewed
  103. through different frames, so, if you don't want to save the paths of the
  104. shapes with the shape, but with the frame, you could have the shapes doing
  105. very different things in all the different frames.
  106.  
  107. Hope this is of help to you.
  108.  
  109. Arni
  110.  
  111.